Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support comb textfields for printing #12177

Merged
merged 1 commit into from
Aug 9, 2020
Merged

Conversation

calixteman
Copy link
Contributor

No description provided.

@calixteman calixteman changed the title Comb Support comb textfields for printing Aug 5, 2020
@timvandermeij timvandermeij added annotations form-acroform printing Gecko 81 Tracking work planned for Form Fill in Shirley 81 release labels Aug 5, 2020
Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with these comments addressed. (I only checked the last commit for this PR since the rest is in other PRs.)

@@ -987,6 +987,22 @@ class WidgetAnnotation extends Annotation {
const vPadding = defaultPadding + Math.abs(descent) * fontSize;
const defaultAppearance = this.data.defaultAppearance;

if (this.data.comb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since comb is a specific property of text widget annotations (and not other widget annotations), this code should live in the TextWidgetAnnotation class instead.

let first = true;
for (const character of value) {
if (first) {
buf += ` (${character}) Tj`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the number of intermediate strings being created, we normally don't append strings to strings. Instead, we push all strings to an array and join them at the end, which is a bit more efficient. Can we do that here as well? Look at

const romanBuf = [];
let pos;
// Thousands
while (number >= 1000) {
number -= 1000;
romanBuf.push("M");
}
// Hundreds
pos = (number / 100) | 0;
number %= 100;
romanBuf.push(ROMAN_NUMBER_MAP[pos]);
// Tens
pos = (number / 10) | 0;
number %= 10;
romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
// Ones
romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
const romanStr = romanBuf.join("");
for the pattern we use.

Moreover, this will also fix the line let buf = ... above since that is longer than the 80 character limit. If we split that large string into two strings we can simply push those into the array so it fits with the character limit again (I'm surprised ESLint doesn't complain about this already...).

}, done.fail)
.then(appearance => {
expect(appearance).toEqual(
"/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 2 Tm (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj ET Q EMC"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line also exceeds the 80 character limit. Please split it up by concatenating smaller substrings.

@@ -987,6 +987,22 @@ class WidgetAnnotation extends Annotation {
const vPadding = defaultPadding + Math.abs(descent) * fontSize;
const defaultAppearance = this.data.defaultAppearance;

if (this.data.comb) {
const combWidth = (totalWidth / this.data.maxLen).toFixed(2);
Copy link
Contributor

@timvandermeij timvandermeij Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent this method from being too big, I would suggest to move the comb handling code to a private method named _getCombAppearance similar to what you did for the multiline strings.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2020

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/d16429acffb4e81/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/d16429acffb4e81/output.txt

Total script time: 3.48 mins

Published

@timvandermeij
Copy link
Contributor

The combs work fine, it's only the multiline text fields that don't work. For completeness I'm attaching the document where the comb is rendered, but the multiline is not:

out.pdf

@timvandermeij
Copy link
Contributor

This requires a rebase after the multiline text PR.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 1

Live output at: http://54.67.70.0:8877/8be6a46f4f79845/output.txt

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 2

Live output at: http://54.67.70.0:8877/6d6248273243b79/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 1

Live output at: http://54.215.176.217:8877/2ccc06a49e28fae/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/8be6a46f4f79845/output.txt

Total script time: 3.37 mins

Published

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/6d6248273243b79/output.txt

Total script time: 27.16 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/6d6248273243b79/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Aug 9, 2020

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/2ccc06a49e28fae/output.txt

Total script time: 30.07 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/2ccc06a49e28fae/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit 6620861 into mozilla:master Aug 9, 2020
@timvandermeij
Copy link
Contributor

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotations form-acroform Gecko 81 Tracking work planned for Form Fill in Shirley 81 release printing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants